@extends('common')
@section('content')
        <form class="form-inline definewidth m20" action="{{url('human/maintain')}}" method="get">
            编号：<input type="text" name="use_num" id=""class="abc input-default" placeholder="" value="" style="width: 150px;">
            姓名：<input type="text" name="use_name" id=""class="abc input-default" placeholder="" value="" style="width: 150px;">
            身份证：<input type="text" name="use_card" id=""class="abc input-default" placeholder="" value="" style="width: 150px;">
            手机号：<input type="text" name="use_phone" id=""class="abc input-default" placeholder="" value="" style="width: 150px;">
            <input type="hidden" name="type" value="2">
            岗位 <select name="use_position" id=""  style="width: 150px;">
                <option value="">*请选择*</option>
                @foreach($post as $pt)
                <option value="{{$pt->position}}">{{$pt->position}}</option>
                @endforeach
            </select>
            <button type="button" class="btn btn-primary" id="search">查询</button>
            <button type="submit" class="btn btn-success" >导出</button>
        </form>
        <div id="replace">
        <table class="table table-bordered table-hover definewidth m10">
            <thead>
            <tr>
                <th>序号</th>
                <th>姓名</th>
                <th>编号</th>
                <th>身份证号</th>
                <th>出生年月</th>
                <th>性别</th>
                <th>岗位</th>
                <th>合同结束日期</th>
                <th>联系电话</th>
                <th>操作</th>
            </tr>
            </thead>
            @foreach($user['data'] as $o)
            <tr>
                <td>{{$o['use_id']}}</td>
                <td>{{$o['use_name']}}</td>
                <td>{{$o['use_num']}}</td>
                <td>{{$o['use_card']}}</td>
                <td>{{$o['use_birthday']}}</td>
                <td>@if($o['use_sex']){{'男'}}@else{{'女'}}@endif</td>
                <td>{{$o['use_position']}}</td>
                <td>{{$o['use_contractend']}}</td>
                <td>{{$o['use_phone']}}</td>
                <td idval="{{$o['use_id']}}">@if($o['use_status']==1){!! '<div><a href="javascript:;" class="edit">修改</a>|','|<a  href="javascript:;" ide="+{{$o->use_id}}+" class="quit">离职</a></div>' !!}@else{{"已离职"}}@endif</td>
            </tr>
            @endforeach
        </table>
            <div class="inline pull-right page">
                {{$user['total']}} 条记录 {{$user['current_page']}}/{{$user['last_page']}} 页
                <a href='{{url('human/maintain')}}' >首页</a>
                <a href='{{$user['prev_page_url']}}'>上一页</a>
                @for($i=1;$i<=$user['last_page'];$i++)
                    @if($i==$user['current_page'])
                        <a href='{{url('human/maintain').'?page='.$i}}'><font color="red">{{$i}}</font></a>
                        @else
                        <a href='{{url('human/maintain').'?page='.$i}}'>{{$i}}</a>
                    @endif
                    @endfor
                <a href='{{$user['next_page_url']}}'>下一页</a>
                <a href='{{url('human/maintain').'?page='.$user['last_page']}}' >末页</a>
            </div>
    </div>
    <script type="text/javascript">
        $(function(){
            $(document).on('click','.edit',function(){
                id=$(this).parent().parent().attr('idval');
                window.location.href="{{url('human/maintainedit')}}?id="+id;
            })
            $(document).on('click','.quit',function(){
                that=$(this)
                if(confirm("您确定要执行操作吗？")){
                    id=that.parent().parent().attr('idval');
                    $.get('{{url('human/maintain')}}',{id:id,type:1},function(data){
                        if(data==1){
                            that.parent().text('已离职');
                        }else{
                            alert('您权限不够')
                        }
                    })
                }
            })
            $('#search').click(function(){
                search=($("form").serialize());
                $.get('{{url('human/maintain')}}',search,function(data){
                   $('#replace').html(data)
                })
            })

        })
    </script>
@stop